package com.springmongodb.respository;

import com.springmongodb.pojo.Book;
import org.springframework.data.mongodb.repository.MongoRepository;
import org.springframework.data.mongodb.repository.Query;

import java.util.*;

public interface BookRepository extends MongoRepository<Book, Integer> {
	List<Book> findByAuthor(String author);
	List<Book> findByCategoryAndAuthor(String category, String author);
	List<Book> findByPriceBetween(double price,double maxcPrice);
	List<Book> findByNameLike(String name);

	@Query("{'category':?0}")
	List<Book> findCategory(String category);
	@Query("{'price':{'$lte':?0}}")
	List<Book> findPrice(double price);
	@Query("{'name': {$regex:?0},'category': ?1}")
	List<Book> searchBooks(String name,String category);
}
